package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 会话事件源枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum SessionEventSource implements BaseEnum {
    /** 客户端 */
    CLIENT("CLIENT", "客户端"),
    /** 服务端 */
    SERVER("SERVER", "服务端"),
    /** 数据库 */
    DATABASE("DATABASE", "数据库"),
    /** 缓存 */
    CACHE("CACHE", "缓存"),
    /** 消息队列 */
    MESSAGE_QUEUE("MESSAGE_QUEUE", "消息队列"),
    /** 文件系统 */
    FILE_SYSTEM("FILE_SYSTEM", "文件系统"),
    /** 外部系统 */
    EXTERNAL_SYSTEM("EXTERNAL_SYSTEM", "外部系统"),
    /** 第三方服务 */
    THIRD_PARTY("THIRD_PARTY", "第三方服务"),
    /** 监控系统 */
    MONITOR("MONITOR", "监控系统"),
    /** 日志系统 */
    LOG_SYSTEM("LOG_SYSTEM", "日志系统");
    
    private final String code;
    private final String description;
    
    SessionEventSource(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    @Override
    public String getCode() {
        return code;
    }
    
    @Override
    public String getDescription() {
        return description;
    }
    
    public static SessionEventSource fromCode(String code) {
        for (SessionEventSource source : values()) {
            if (source.getCode().equals(code)) {
                return source;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
    
    public static SessionEventSource fromDescription(String description) {
        for (SessionEventSource source : values()) {
            if (source.getDescription().equals(description)) {
                return source;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }
    
    @Override
    public String toString() {
        return description;
    }
}